package com.leyou.item.api;

import com.leyou.common.dto.CartDTO;
import com.leyou.common.vo.PageResult;
import com.leyou.item.pojo.Sku;
import com.leyou.item.pojo.SpuBo;
import com.leyou.item.pojo.SpuDetail;
import org.springframework.web.bind.annotation.*;

import java.util.List;

public interface GoodsAPI {

    @GetMapping("spu/page")
    PageResult<SpuBo> querySpuPage(
            @RequestParam(value = "key", required = false) String key,
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "saleable", required = false) Boolean saleable);

    @GetMapping("spu/detail/{spuId}")
    SpuDetail querySpuDetailBySpuId(@PathVariable("spuId") Long spuId);

    @GetMapping("sku/list")
    List<Sku> querySkuBySpuId(@RequestParam("id") Long spuId);

    @GetMapping("spu/{spuId}")
    SpuBo querySpuBySpuId(@PathVariable("spuId") Long spuId);

    /**
     * 减库存
     *
     * @param cartDTOList
     * @return
     */
    @PostMapping("stock/decrease")
    void decreaseStock(@RequestBody List<CartDTO> cartDTOList);

    /**
     * 根据skuIds查询sku集合数据
     *
     * @param skuIds
     * @return
     */
    @GetMapping("sku/list/ids")
    List<Sku> querySkuBySkuIds(@RequestParam("ids") List<Long> skuIds);

}
